package com.lagou.edu.utils;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * @author 应癫
 */
public class DruidUtils {

    private DruidUtils() {
    }

    private static final DruidDataSource DRUID_DATA_SOURCE = new DruidDataSource();

    static {
        Properties properties = JdbcProperties.loadJdbcProperties(JdbcProperties.JDBC_PROPERTIES_NAME);

        DRUID_DATA_SOURCE.setDriverClassName(properties.getProperty("jdbc.driver-class-name"));
        DRUID_DATA_SOURCE.setUrl(properties.getProperty("jdbc.url"));
        DRUID_DATA_SOURCE.setUsername(properties.getProperty("jdbc.username"));
        DRUID_DATA_SOURCE.setPassword(properties.getProperty("jdbc.password"));

    }

    public static DataSource getInstance() {
        return DRUID_DATA_SOURCE;
    }

}
